package com.jk.controller;

import com.jk.bean.Count;
import com.jk.service.TuService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("echars")
public class TuController {
    @Resource
    private TuService tuService;

    //===管理图
    @ResponseBody
    @RequestMapping("getOne")
    public Map<String, Object> getOne() {
    Map<String, Object> params = new HashMap<>();

    ArrayList<String> a = new ArrayList<>();

    ArrayList<Integer> b = new ArrayList<>();

    List<Count> count = tuService.getOne();

        for (Count zhuzhuang : count) {

        a.add(zhuzhuang.getName());
        b.add(Integer.valueOf(zhuzhuang.getValue()));
    }
        params.put("categories", a);
        params.put("data", b);
        System.out.println(params);
        return params;
}

  //=====点击量
    @ResponseBody
    @RequestMapping("getTwo")
    public Map<String, Object> getTwo() {
        Map<String, Object> param = new HashMap<>();

        ArrayList<String> a = new ArrayList<>();

        ArrayList<Integer> b = new ArrayList<>();

        List<Count> count = tuService.getTwo();

        for (Count count1 : count) {
            a.add(count1.getName());
            b.add(Integer.valueOf(count1.getValue()));
        }

        param.put("categories", a);
        param.put("data", b);
        System.out.println(param);
        return param;
    }

   //====关注量

    @ResponseBody
    @RequestMapping("getThree")
    public Map<String, Object> getThree() {
        Map<String, Object> param = new HashMap<>();

        ArrayList<String> a = new ArrayList<>();

        ArrayList<Integer> b = new ArrayList<>();

        List<Count> count = tuService.getThree();

        for (Count count1 : count) {
            a.add(count1.getName());
            b.add(Integer.valueOf(count1.getValue()));
        }

        param.put("categories", a);
        param.put("data", b);
        System.out.println(param);
        return param;
    }


    @ResponseBody
    @RequestMapping("getFour")
    public Map<String, Object> getFour() {
        Map<String, Object> param = new HashMap<>();

        ArrayList<String> a = new ArrayList<>();

        ArrayList<Integer> b = new ArrayList<>();

        List<Count> count = tuService.getFour();

        for (Count count1 : count) {
            a.add(count1.getName());
            b.add(Integer.valueOf(count1.getValue()));
        }

        param.put("categories", a);
        param.put("data", b);
        System.out.println(param);
        return param;
    }

    @ResponseBody
    @RequestMapping("getFive")
    public List<Count> getFive() {
        return tuService.getFive();

    }

    //=======
    @ResponseBody
    @RequestMapping("getSix")
    public List<Count> getSix(){

        return tuService.getSix();

    }

    //===getRet
    @ResponseBody
    @RequestMapping("getRet")
    public List<Count> getRet(){
        return tuService.getRet();
    }


    //=======三线
    @ResponseBody
    @RequestMapping("getSeven")
    public Map<String, Object> getSeven(){
        Map<String, Object> param = new HashMap<>();

        ArrayList<String> a = new ArrayList<>();

        ArrayList<Integer> b = new ArrayList<>();

   //===月排行
        List<Count> coun1 = tuService.getSev();

        for (Count count1 : coun1) {
            a.add(count1.getName());
            b.add(Integer.valueOf(count1.getValue()));
        }

        param.put("categories1", a);
        param.put("data1", b);
         //===周排行

        List<Count> coun2 = tuService.getSe();

        for (Count count1 : coun2) {
            a.add(count1.getName());
            b.add(Integer.valueOf(count1.getValue()));
        }
        param.put("data2", b);

  //====日排行
        List<Count> coun3 = tuService.getSe1();
        for (Count count1 : coun3) {

            b.add(Integer.valueOf(count1.getValue()));
        }
        param.put("data3", b);

        List<Count> count = tuService.getName();

        for (Count count1 : count) {
            a.add(count1.getName());
        }

        param.put("categories", a);
        return param;

    }

   //====标题
    @ResponseBody
    @RequestMapping("getNr")
    public List<Count> getNr(){


        return tuService.getNr();
    }
}
